package com.takeshi.landlords.util;

import java.util.stream.Stream;

/**
 * UserState
 *
 * @author Nanase Takeshi
 * @date 2022/2/21 16:33
 */
public enum UserState {

    /**
     * 选择[创建房间/加入房间]界面
     */
    BASE_CHOOSE(0),
    /**
     * 选择加入房间的选择房间号界面
     */
    JOIN_ROOM(1),
    /**
     * 输入房间密码界面
     */
    ENTER_PWD(2),
    /**
     * 等待房主开始游戏
     */
    WAITING_FOR_GAME_START(3),
    /**
     * 发牌后选举地主
     */
    CHOOSE_LANDLORD(4),
    /**
     * 在比赛中
     */
    IN_COMPETITION(5);

    private int state;

    UserState(int state) {
        this.state = state;
    }

    public int getState() {
        return state;
    }

    public static boolean inTheRoom(Integer state) {
        return Stream.of(WAITING_FOR_GAME_START, CHOOSE_LANDLORD, IN_COMPETITION).anyMatch(item -> item.getState() == state);
    }

}
